import request from '@/utils/request';
import { API_VERSION } from '@/utils';

// 问卷列表
export const getSurveyList = data => request({
  url: `/${API_VERSION}/questionnaireForm/page`,
  method: 'post',
  data
});

// 创建/修改 问卷
export const saveSurvey = data => request({
  url: `/${API_VERSION}/questionnaireForm`,
  method: 'post',
  data
});
// 问卷详情
export const getSurveyDetail = params => request({
  url: `/${API_VERSION}/questionnaireForm/detail/${params.questionnaireFormId}`,
  method: 'get',
  params
});

// 问卷状态变更
export const changeStatus = data => request({
  url: `/${API_VERSION}/questionnaireForm/status/${data.questionnaireFormId}/${data.status}`,
  method: 'post',
  data
});

// 复制问卷
export const copySurvey = data => request({
  url: `/${API_VERSION}/questionnaireForm/copy/${data.questionnaireFormId}`,
  method: 'post',
  data
});

// 提醒填写问卷
export const remindSurvey = data => request({
  url: `/${API_VERSION}/questionItem/push/${data.questionnaireFormId}`,
  method: 'post',
  data
});

// 批量删除问卷
export const deleteSurvey = data => request({
  url: `/${API_VERSION}/questionnaireForm/remove`,
  method: 'post',
  data
});

// 导出问卷统计数据
export const downloadSurvey = data => request({
  url: `/${API_VERSION}/questionnaireForm/export`,
  method: 'post',
  data,
  responseType: 'blob'
});

// 问卷项周期列表
export const getCycleList = params => request({
  url: `/${API_VERSION}/questionItem/cycle/${params.questionnaireFormId}`,
  method: 'get'
});